# 封装
# class Person:
#     name = "zhansan"
#
#
# pe = Person()
# print(pe.name)
# Person.name = "lisi"
# print(Person.name)

# 隐藏属性
class Person:
    name = "zhansan"
    __age = 18

    def introduce(self):
        print(f"{Person.name}的年龄是{Person.__age}")


pe = Person()
print(pe.name)

# print(pe._Person__age)
pe.introduce()


class Person:
    name = "zhangsan"
    __age = 18  # 隐藏属性
    _sex = '男'  # 私有属性


pe = Person()
print(pe._sex)
print(pe._Person__age)


class Man:
    def __pay(self):  # 隐藏方法
        print("玩手机", self)

    def funa(self):
        print("普通方法", self)
        self.__pay()

    def _buy(self):
        print("买东西", self)


ma = Man()
ma.funa()
ma._buy()


